#include "FileReader.h"

FileReader::FileReader(){

}
FileReader::~FileReader(){
	if (readFile.is_open())
		readFile.close();

}

bool FileReader::OpenFile(char* file_path){
	readFile.open(file_path);
	return readFile.is_open();
}
bool FileReader::CloseFile(){
	readFile.close();
	return !readFile.is_open();
}
std::string FileReader::ReadLine(){
	if(readFile.is_open() && !readFile.eof()){
		getline(readFile,lineBuffer);
		return lineBuffer;
	}
	else
		return "";
}
std::string FileReader::ReadToken(){
	if(readFile.is_open() && !readFile.eof()){
		readFile >> tokenBuffer;
		return tokenBuffer;
	}
	else
		return "";
}
bool FileReader::TokenizeFile(){
	tokens.clear();
	std::string token = "";
	while(!readFile.eof()) // To get you all the lines.
	{
		token = ReadToken();
		tokens.push_back(token);
	}
	return true;
}
std::string FileReader::GetToken(unsigned int i){
	if(i < tokens.size())
		return tokens.at(i);
	else
		return "";
}
unsigned int FileReader::GetTotalTokens(){
	return tokens.size();
}